<?php

namespace App\Models;

use Illuminate\Database\Eloquent\SoftDeletes;

class Link extends Model
{
    use SoftDeletes;

    protected $dates = ['deleted_at'];

    protected $guarded = [];

    public function getWaitAudit()
    {
        return $this->where("audit_status", self::FALSE_STATUS)->get()->toArray();
    }

    public function getLinkList()
    {
        return $this->where('audit_status', self::TRUE_STATUS)->get()->toArray();
    }

    public function auditLink($id)
    {
        return $this->where('id', $id)->update(["audit_status" => self::FALSE_STATUS, "is_enable" => self::TRUE_STATUS]);
    }

    public function enableLink($id, $status)
    {
        return $this->where('id', $id)->update(["is_enable" => $status]);
    }
}
